/**
 * 
 */
package nl.sportan.samenloop;

import java.util.ArrayList;

import nl.sportan.samenloop.adapter.ImagePageAdapter;
import nl.sportan.samenloop.communication.PhotosetTarget;
import nl.sportan.samenloop.communication.flickr.PhotosetRetriever;
import android.app.Activity;
import android.os.Bundle;
import android.os.Handler;
import android.support.v4.view.ViewPager;
import android.view.Window;

import com.gmail.yuyang226.flickr.photosets.Photoset;

/**
 * @author Bram Wiekens
 *
 */
public class FlickrActivity extends Activity implements PhotosetTarget {

	//private final static String TAG = "FLickrView";
	
	private Handler handler;
	
	private ArrayList<Photoset> photosets;
	
	//private GridView photoGrid;
	
	public FlickrActivity() {
		handler = new Handler();
	}
	
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);

		requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);

		setContentView(R.layout.flickr_view);

		/*photoGrid = (GridView) findViewById(R.id.photogrid);
		photoGrid.setOnItemClickListener(new PhotosetListener());*/
		
		getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE,
				R.layout.title_bar);
		
		
		Thread t = new Thread(new PhotosetRetriever(this)); 
		t.start();
	}


	
	

	public void setPhotoSet(ArrayList<Photoset> photosets) {
		this.photosets = photosets;
		
		handler.post(new PhotosetUpdater());
		
	}
	
	private class PhotosetUpdater implements Runnable{
		
		public void run() {
			/*PhotosetAdapter img = new PhotosetAdapter(FlickrActivity.this, photosets);
			photoGrid.setAdapter(img);*/
			ViewPager vp = (ViewPager) findViewById(R.id.pager);
			vp.setAdapter(new ImagePageAdapter(FlickrActivity.this,photosets));
		}
		
	}

		
}
